﻿/*
 * @Autor: PK
 * @Date: 2021/12/30 20:39:SS
 */

using System.Collections;
using GMap.NET;
using ShkSimulation.core.util.osm;

namespace ShkSimulation.desktop.util {

	public static class Extensions {

		public static RectLatLng Cast(this Bound bound) {
			return RectLatLng.FromLTRB(bound.MinLongitude, bound.MaxLatitude, bound.MaxLongitude, bound.MinLatitude);
		}
		
		public static Bound Cast(this RectLatLng rect) {
			return new Bound(rect.Bottom, rect.Left, rect.Top, rect.Right);
		}

		public static int Count(this IEnumerable source) {
			var col = source as ICollection;
			if (col != null) {
				return col.Count;
			}
			int c = 0;
			foreach (var unused in source) {
				c++;
			}
			return c;
		}
		
		public static object First(this IEnumerable source) {
			foreach (var unused in source) {
				return unused;
			}
			return null;
		}

	}

}